###############################################
# === xenomorph_general_events.txt ===
###############################################
###############################################
# Xenomorph General Events
#
# Contains general Xenomorph events not bound to one origin,
# specific trait chain, or external mod compatibility.
###############################################

namespace = xenogeneral

# xenogeneral.1 — Spawns the Xenomorph Prime system at game start
# FIX M2: Changed "event" to "country_event" for correct scope (on_game_start fires in country scope)
country_event = {
	id = xenogeneral.1
	hide_window = yes
	is_triggered_only = yes
	fire_only_once = yes
	immediate = {
		random_rim_system = {
			spawn_system = {
				min_distance = 20
				max_distance = 50
				initializer = "xenomorph_prime_system"
			}
		}
	}
}

# xenogeneral.2 — Fires when a fleet enters the Xenomorph Prime system
fleet_event = {
	id = xenogeneral.2
	is_triggered_only = yes
	title = xenogeneral.2.title
	desc = xenogeneral.2.desc
	picture = GFX_evt_barren_planet
	location = from
	fire_only_once = yes
	trigger = {
		from = { has_planet_flag = xenomorph_prime }
	}
	option = {
		name = xenogeneral.2.a
	}
}

# xenogeneral.3 — Fires when a fleet surveys Xenomorph Prime and recovers the Queen Mother DNA
fleet_event = {
	id = xenogeneral.3
	is_triggered_only = yes
	title = xenogeneral.3.title
	desc = xenogeneral.3.desc
	picture = GFX_evt_exploding_planet
	location = from
	fire_only_once = yes
	trigger = {
		from = { has_planet_flag = xenomorph_prime }
	}
	option = {
		name = OK
		add_resource = { unity = 10000 }
		if = {
			limit = {
				NOT = { has_global_flag = xenomorph_dna_discovered }
			}
			add_relic = r_xenomorph_queen_mother_dna
			set_global_flag = xenomorph_dna_discovered
		}
	}
}

###############################################
# xenogeneral.5 — Vanilla building name override trigger
# Fires when a Xenomorph empire colonises a planet.
# Sets a planet flag used by localisation to display
# Xenomorph-themed building names.
###############################################

country_event = {
	id = xenogeneral.5
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_owned_species = { has_trait = trait_xenomorph }
	}

	immediate = {
		every_owned_planet = {
			limit = {
				any_owned_pop_group = { is_xenomorph = yes }
				NOT = { has_planet_flag = xenomorph_colony }
			}
			set_planet_flag = xenomorph_colony
		}

		# Any Hive World OR Xenomorph Hive World held by a Xenomorph empire gets the Xenomorph Hive World flag.
		# The flag enables the special districts; the modifier provides the visible planetary bonus.
		every_owned_planet = {
			limit = {
				OR = { is_planet_class = pc_hive is_planet_class = pc_xenomorph_hive }
				NOT = { has_planet_flag = xenomorph_hive_world }
			}
			set_planet_flag = xenomorph_hive_world
		}

		every_owned_planet = {
			limit = {
				has_planet_flag = xenomorph_hive_world
				NOT = { has_modifier = xenomorph_hive_world }
			}
			add_modifier = { modifier = xenomorph_hive_world days = -1 }
		}
	}
}

###############################################
# XENOMORPH STARTING BUILDING SWAP
# Put in: events/xenomorph_starting_buildings_events.txt
###############################################

namespace = xenomorph_start

country_event = {
	id = xenomorph_start.1
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		NOT = { has_country_flag = xenomorph_starting_buildings_added }
		xeno_is_xenomorph_hive_country = yes
		capital_scope = { exists = this }
	}

	immediate = {
		set_country_flag = xenomorph_starting_buildings_added

		capital_scope = {
			if = {
				limit = { has_building = building_foundry_1 }
				remove_building = building_foundry_1
			}

			if = {
				limit = { has_building = building_hydroponics_farm }
				remove_building = building_hydroponics_farm
			}

			if = {
				limit = { has_building = building_synapse_node }
				remove_building = building_synapse_node
			}

			if = {
				limit = { has_building = building_logistics_center }
				remove_building = building_logistics_center
			}

			if = {
				limit = { has_building = building_research_lab_1 }
				remove_building = building_research_lab_1
			}
		}
	}
}

###############################################
# XENOMORPH VANILLA BUILDING LOCKOUT / SWAP
# Purpose:
# - Removes vanilla buildings from Xenomorph Hive planets.
# - Adds Xenomorph replacement buildings by category.
# - This handles existing/starting buildings. To hide vanilla
#   build options from the construction UI, the vanilla building
#   definitions must also have the blocker trigger from
#   xenomorph_vanilla_building_blocker_triggers.txt added to
#   their potential blocks.
###############################################

country_event = {
	id = xenomorph_start.2
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		xeno_is_xenomorph_hive_country = yes
	}

	immediate = {
		every_owned_planet = {
			limit = {
				is_colony = yes
				any_owned_pop_group = { is_xenomorph = yes }
			}

			# --- Capital / colony shelters ---
			if = { limit = { has_building = building_colony_shelter } remove_building = building_colony_shelter }
			if = { limit = { has_building = building_capital } remove_building = building_capital }
			if = { limit = { has_building = building_major_capital } remove_building = building_major_capital }
			if = { limit = { has_building = building_system_capital } remove_building = building_system_capital }
			if = { limit = { has_building = building_hive_capital } remove_building = building_hive_capital }
			if = { limit = { has_building = building_hive_major_capital } remove_building = building_hive_major_capital }
			if = { limit = { has_building = building_hive_system_capital } remove_building = building_hive_system_capital }
			if = { limit = { has_building = building_machine_capital } remove_building = building_machine_capital }
			if = { limit = { has_building = building_machine_major_capital } remove_building = building_machine_major_capital }
			if = { limit = { has_building = building_machine_system_capital } remove_building = building_machine_system_capital }

			# Add Xenomorph capital chain if no royal capital is present.
			if = {
				limit = {
					is_capital = yes
					owner = { has_origin = origin_xenomorph_queen_mother }
					NOT = { has_building = building_xenomorph_queen_mother_hive }
				}
				add_building = building_xenomorph_queen_mother_hive
			}
			if = {
				limit = {
					OR = {
						NOT = { is_capital = yes }
						owner = { NOT = { has_origin = origin_xenomorph_queen_mother } }
					}
					NOR = {
						has_building = building_xenomorph_queens_nest_1
						has_building = building_xenomorph_planetary_hive
						has_building = building_xenomorph_matriarch_hive
						has_building = building_xenomorph_brood_queen_hive
						has_building = building_xenomorph_empress_hive
						has_building = building_xenomorph_war_matriarch_hive
					}
				}
				add_building = building_xenomorph_queens_nest_1
			}

			# --- Pop assembly / growth ---
			if = { limit = { has_building = building_spawning_pool } remove_building = building_spawning_pool }
			if = { limit = { has_building = building_clone_vats } remove_building = building_clone_vats }
			if = { limit = { has_building = building_robot_assembly_plant } remove_building = building_robot_assembly_plant }
			if = { limit = { has_building = building_machine_assembly_plant } remove_building = building_machine_assembly_plant }

			# --- Alloy / manufacturing ---
			if = { limit = { has_building = building_foundry_1 } remove_building = building_foundry_1 }
			if = { limit = { has_building = building_foundry_2 } remove_building = building_foundry_2 }
			if = { limit = { has_building = building_foundry_3 } remove_building = building_foundry_3 }
			if = { limit = { has_building = building_alloy_mega_forges } remove_building = building_alloy_mega_forges }
			if = { limit = { has_building = building_alloy_nano_plants } remove_building = building_alloy_nano_plants }
			if = { limit = { has_building = building_factory_1 } remove_building = building_factory_1 }
			if = { limit = { has_building = building_factory_2 } remove_building = building_factory_2 }
			if = { limit = { has_building = building_factory_3 } remove_building = building_factory_3 }
			if = { limit = { has_building = building_civilian_industry } remove_building = building_civilian_industry }

			# --- Food / biomass ---
			if = { limit = { has_building = building_hydroponics_farm } remove_building = building_hydroponics_farm }
			if = { limit = { has_building = building_food_processing_facility } remove_building = building_food_processing_facility }
			if = { limit = { has_building = building_food_processing_center } remove_building = building_food_processing_center }

			# --- Unity / synapse ---
			if = { limit = { has_building = building_synapse_node } remove_building = building_synapse_node }
			if = { limit = { has_building = building_sensorium_1 } remove_building = building_sensorium_1 }
			if = { limit = { has_building = building_sensorium_2 } remove_building = building_sensorium_2 }
			if = { limit = { has_building = building_sensorium_3 } remove_building = building_sensorium_3 }
			if = { limit = { has_building = building_autochthon_monument } remove_building = building_autochthon_monument }
			if = { limit = { has_building = building_heritage_site } remove_building = building_heritage_site }
			if = { limit = { has_building = building_hypercomms_forum } remove_building = building_hypercomms_forum }
			if = { limit = { has_building = building_simulation_1 } remove_building = building_simulation_1 }
			if = { limit = { has_building = building_simulation_2 } remove_building = building_simulation_2 }
			if = { limit = { has_building = building_simulation_3 } remove_building = building_simulation_3 }

			# --- Amenities / maintenance ---
			if = { limit = { has_building = building_logistics_center } remove_building = building_logistics_center }
			if = { limit = { has_building = building_maintenance_depot } remove_building = building_maintenance_depot }
			if = { limit = { has_building = building_holo_theatres } remove_building = building_holo_theatres }
			if = { limit = { has_building = building_hyper_entertainment_forum } remove_building = building_hyper_entertainment_forum }

			# --- Research ---
			if = { limit = { has_building = building_research_lab_1 } remove_building = building_research_lab_1 }
			if = { limit = { has_building = building_research_lab_2 } remove_building = building_research_lab_2 }
			if = { limit = { has_building = building_research_lab_3 } remove_building = building_research_lab_3 }
			if = { limit = { has_building = building_institute } remove_building = building_institute }

			# --- Defense / army ---
			if = { limit = { has_building = building_stronghold } remove_building = building_stronghold }
			if = { limit = { has_building = building_fortress } remove_building = building_fortress }


			# --- T1 amenity (Resin Spire) ---

			# --- T1 unity (Pheromone Node) ---

			# --- T1 defense (Drone's Nest) ---

			# --- T1 manufacturing (Carapace Forge) — civic-gated ---
		}
	}
}


###############################################
# Pass 34: Pre-built starting buildings on NEW colonies.
# Fires on on_colony_established for Xenomorph empires.
# Mirrors the homeworld setup in xenomorph_start.2 but for colonies
# founded after game start.
#
# Core (Decision B): every Xeno colony gets the capital + defense + growth
# trio pre-built, so a new colony is immediately functional:
#   - Queen Nest (capital)         building_xenomorph_queens_nest_1
#   - Offspring Nest (growth)      building_xenomorph_royal_jelly_pods
# Queen Mother origin CAPITAL instead gets the royal trio:
#   - Queen Mother Throne          building_xenomorph_queen_mother_hive
#   - Offspring Nest               building_xenomorph_royal_jelly_pods
###############################################
country_event = {
	id = xenomorph_start.3
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		xeno_is_xenomorph_hive_country = yes
	}

	immediate = {
		# FROMFROM / FROM scope for on_colony_established is the planet via root.
		# Use the colony that was just established.
		event_target:xeno_new_colony_planet = {
			# --- Strip any vanilla capital / growth / amenity that was auto-placed ---
			if = { limit = { has_building = building_colony_shelter } remove_building = building_colony_shelter }
			if = { limit = { has_building = building_capital } remove_building = building_capital }
			if = { limit = { has_building = building_hive_capital } remove_building = building_hive_capital }
			if = { limit = { has_building = building_hive_major_capital } remove_building = building_hive_major_capital }
			if = { limit = { has_building = building_spawning_pool } remove_building = building_spawning_pool }
			if = { limit = { has_building = building_offspring_nest } remove_building = building_offspring_nest }
			if = { limit = { has_building = building_hive_warren } remove_building = building_hive_warren }

			# === Capital: Queen Mother Throne on QM capital, else Queen Nest ===
			if = {
				limit = {
					is_capital = yes
					owner = { has_origin = origin_xenomorph_queen_mother }
					NOT = { has_building = building_xenomorph_queen_mother_hive }
				}
				add_building = building_xenomorph_queen_mother_hive
			}
			if = {
				limit = {
					OR = {
						NOT = { is_capital = yes }
						owner = { NOT = { has_origin = origin_xenomorph_queen_mother } }
					}
					NOR = {
						has_building = building_xenomorph_queens_nest_1
						has_building = building_xenomorph_planetary_hive
						has_building = building_xenomorph_matriarch_hive
						has_building = building_xenomorph_brood_queen_hive
						has_building = building_xenomorph_empress_hive
						has_building = building_xenomorph_war_matriarch_hive
						has_building = building_xenomorph_queen_mother_hive
					}
				}
				add_building = building_xenomorph_queens_nest_1
			}



			# === Growth: Offspring Nest (Royal Jelly Pods) on every colony ===
		}
	}
}


# Pass 34: Bridge from on_colony_established (planet scope) to xenomorph_start.3.
# Saves the new colony as an event target, then fires the country-scope build event.
planet_event = {
	id = xenomorph_start.4
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	immediate = {
		save_event_target_as = xeno_new_colony_planet
		owner = { country_event = { id = xenomorph_start.3 } }
	}
}

###############################################
# === xenomorph_narrative_events.txt ===
###############################################
###############################################
# XENOMORPH NARRATIVE EVENTS
#
# - Queen Mother death chain (xeno_queen_mother.200+): she dies, a Paladin
#   ascends, paid for at heavy cost across several events.
# - Hostline first-contact (xeno_meet.1): flavour on meeting a new empire.
# - Hybrid emergence (xeno_hybrid.1): a new hostline strain emerges.
# - Xenodragon awakening (xeno_draconic.500): an apex creature awakens.
#
# All written in a narrative register. Pictures use existing Hive event art.
###############################################

namespace = xeno_queen_mother

#####################################################################
# QUEEN MOTHER DEATH CHAIN
#####################################################################

# .200 - GATE (hidden). Fired from on_leader_death. ROOT = dying leader.
# If the dead leader was the Queen Mother (immortal trait) of a QM-origin hive,
# begin the succession crisis.
country_event = {
	id = xeno_queen_mother.200
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		# ROOT is the dying leader; check the trait + owner.
		if = {
			limit = {
				has_trait = leader_trait_xenomorph_queen_mother_immortal
				exists = owner
				owner = { is_xenomorph_empire = yes }
			}
			owner = { country_event = { id = xeno_queen_mother.201 } }
		}
	}
}

# .201 - The Queen Mother is dead (shown). The hive reels; a successor must rise.
country_event = {
	id = xeno_queen_mother.201
	title = "xeno_queen_mother.201.title"
	desc = "xeno_queen_mother.201.desc"
	picture = GFX_evt_Hive_Female_captured_queen1
	is_triggered_only = yes

	immediate = {
		# Empire-wide shock: the broodmind is leaderless.
		add_modifier = { modifier = xenomorph_queen_mother_dead days = 1800 }
	}

	# Option A: Elevate a Paladin now - costly, immediate.
	option = {
		name = "xeno_queen_mother.201.elevate"
		custom_tooltip = "xeno_queen_mother.201.elevate_tt"
		trigger = {
			any_owned_pop = { has_job = xenomorph_paladin }
		}
		hidden_effect = { country_event = { id = xeno_queen_mother.202 } }
	}

	# Option B: Let the brood choose in its own time - cheaper, slower.
	option = {
		name = "xeno_queen_mother.201.wait"
		custom_tooltip = "xeno_queen_mother.201.wait_tt"
		hidden_effect = { country_event = { id = xeno_queen_mother.205 days = 1080 } }
	}
}

# .202 - Elevation ritual begins (shown). The cost of forcing a new Queen.
country_event = {
	id = xeno_queen_mother.202
	title = "xeno_queen_mother.202.title"
	desc = "xeno_queen_mother.202.desc"
	picture = GFX_evt_Hive_Female_Swarm_Hold_established
	is_triggered_only = yes

	# Pay the heavy price: biomass and the brood's strength.
	option = {
		name = "xeno_queen_mother.202.pay"
		custom_tooltip = "xeno_queen_mother.202.pay_tt"
		trigger = {
			resource_stockpile_compare = { resource = food value >= 1000 }
		}
		add_resource = { food = -1000 }
		add_resource = { society_research = -500 }
		hidden_effect = { country_event = { id = xeno_queen_mother.203 days = 720 } }
	}

	# Cannot pay in full: a weaker, unstable elevation.
	option = {
		name = "xeno_queen_mother.202.struggle"
		custom_tooltip = "xeno_queen_mother.202.struggle_tt"
		add_resource = { food = -300 }
		add_modifier = { modifier = xenomorph_unstable_succession days = 3600 }
		hidden_effect = { country_event = { id = xeno_queen_mother.204 days = 720 } }
	}
}

# .203 - A new Queen rises (shown, successful). The Paladin becomes Queen Mother.
country_event = {
	id = xeno_queen_mother.203
	title = "xeno_queen_mother.203.title"
	desc = "xeno_queen_mother.203.desc"
	picture = GFX_evt_Hive_Female_victory1
	is_triggered_only = yes

	immediate = {
		remove_modifier = xenomorph_queen_mother_dead
		# The new ruler takes the Queen Mother mantle.
		ruler = {
			if = {
				limit = { NOT = { has_trait = leader_trait_xenomorph_queen_mother_immortal } }
				add_trait = leader_trait_xenomorph_queen_mother_immortal
			}
		}
		add_modifier = { modifier = xenomorph_new_queen_ascendant days = 3600 }
	}

	option = { name = "xeno_queen_mother.203.ok" }
}

# .204 - An unstable Queen rises (shown, weaker outcome).
country_event = {
	id = xeno_queen_mother.204
	title = "xeno_queen_mother.203.title"
	desc = "xeno_queen_mother.204.desc"
	picture = GFX_evt_Hive_Female_captured_queen2
	is_triggered_only = yes

	immediate = {
		remove_modifier = xenomorph_queen_mother_dead
		ruler = {
			if = {
				limit = { NOT = { has_trait = leader_trait_xenomorph_queen_mother_immortal } }
				add_trait = leader_trait_xenomorph_queen_mother_immortal
			}
		}
		# unstable_succession modifier (added in .202) persists as the cost.
	}

	option = { name = "xeno_queen_mother.204.ok" }
}

# .205 - The brood chooses slowly (shown, the "wait" path resolves).
country_event = {
	id = xeno_queen_mother.205
	title = "xeno_queen_mother.205.title"
	desc = "xeno_queen_mother.205.desc"
	picture = GFX_evt_Hive_Female_Swarm_Hold_established
	is_triggered_only = yes

	immediate = {
		remove_modifier = xenomorph_queen_mother_dead
		ruler = {
			if = {
				limit = { NOT = { has_trait = leader_trait_xenomorph_queen_mother_immortal } }
				add_trait = leader_trait_xenomorph_queen_mother_immortal
			}
		}
		add_modifier = { modifier = xenomorph_new_queen_ascendant days = 1800 }
	}

	option = { name = "xeno_queen_mother.205.ok" }
}


#####################################################################
# HOSTLINE FIRST-CONTACT
#####################################################################
namespace = xeno_meet

# .1 - First contact flavour (shown). Fired from on_first_contact for a Xeno hive.
# The hive regards the newcomer as potential host-stock.
country_event = {
	id = xeno_meet.1
	title = "xeno_meet.1.title"
	desc = "xeno_meet.1.desc"
	picture = GFX_evt_Hive_wild_xenomorph_hunters
	is_triggered_only = yes

	trigger = {
		is_xenomorph_empire = yes
	}

	option = { name = "xeno_meet.1.ok" }
}


#####################################################################
# HYBRID EMERGENCE
#####################################################################
namespace = xeno_hybrid

# .1 - A new hybrid strain emerges (shown). Fires when the hive first produces a
# hostline hybrid - a milestone for the brood's genetic project.
country_event = {
	id = xeno_hybrid.1
	title = "xeno_hybrid.1.title"
	desc = "xeno_hybrid.1.desc"
	picture = GFX_evt_Hive_Female_victory_2
	is_triggered_only = yes

	immediate = {
		add_modifier = { modifier = xenomorph_hybrid_vigor days = 3600 }
	}

	option = { name = "xeno_hybrid.1.embrace" }
	option = {
		name = "xeno_hybrid.1.study"
		add_resource = { society_research = 200 }
	}
}


#####################################################################
# XENODRAGON AWAKENING
#####################################################################
namespace = xeno_draconic

# .500 - The Xenodragon awakens (shown). A apex draconic brood-form stirs.
# Requires the Draconic path; a late-game power spike with a cost.
country_event = {
	id = xeno_draconic.500
	title = "xeno_draconic.500.title"
	desc = "xeno_draconic.500.desc"
	picture = GFX_evt_Hive_male_victory1
	is_triggered_only = yes

	immediate = {
		add_modifier = { modifier = xenomorph_xenodragon_awakened days = -1 }
	}

	option = {
		name = "xeno_draconic.500.unleash"
		custom_tooltip = "xeno_draconic.500.unleash_tt"
	}
}

###############################################
# === xenomorph_picture_events.txt ===
###############################################
###############################################
# Xenomorph Picture / Battle / Encounter Events
#
# General triggered image events for battles, conquests,
# raids, captures, and special encounters.
###############################################

namespace = xeno_pic_events

#########################################################################
# XENOMORPH PICTURE EVENTS
# Adult/NSFW content — capture, defeat, breeding, and victory scenarios.
# All events are triggered by on_actions defined in xenomorph_on_actions.txt
# and xeno_pic_on_actions.txt.
#########################################################################

# ==========================================
# xeno_pic_events.1 — Battle Lost (Female)
# Shown to a non-Xenomorph empire that lost a ground battle to Xenomorphs.
# ==========================================
country_event = {
	id = xeno_pic_events.1
	title = xeno_pic_events.1.name
	desc = {
		trigger = { check_variable = { which = xeno_pic1_variant value = 0 } }
		text = xeno_pic_events.1.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic1_variant value = 1 } }
		text = xeno_pic_events.1.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic1_variant value = 0 } }
		picture = GFX_evt_Hive_Female_battle_lost1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic1_variant value = 1 } }
		picture = GFX_evt_Hive_Female_battle_lost2
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic1_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic1_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.1.a
		every_owned_planet = {
			limit = { has_ground_combat = yes }
			add_modifier = { modifier = xenomorph_post_battle_shock days = 360 }
		}
	}
	option = {
		name = xeno_pic_events.1.b
		add_resource = { unity = -200 }
	}
}

# ==========================================
# xeno_pic_events.2 — Battle Lost (Male)
# Alternate image variant for male-dominant empires.
# ==========================================
country_event = {
	id = xeno_pic_events.2
	title = xeno_pic_events.2.name
	desc = {
		trigger = { check_variable = { which = xeno_pic2_variant value = 0 } }
		text = xeno_pic_events.2.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic2_variant value = 1 } }
		text = xeno_pic_events.2.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic2_variant value = 0 } }
		picture = GFX_evt_Hive_male_battle_lost1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic2_variant value = 1 } }
		picture = GFX_evt_Hive_battle_Lost2
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic2_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic2_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.2.a
		every_owned_planet = {
			limit = { has_ground_combat = yes }
			add_modifier = { modifier = xenomorph_post_battle_shock days = 360 }
		}
	}
	option = {
		name = xeno_pic_events.2.b
		add_resource = { unity = -200 }
	}
}

# ==========================================
# xeno_pic_events.3 — Captured Leader (Female)
# Shown to the Xenomorph empire when they capture an enemy leader.
# The captured leader can be assigned to the Breeding Pit or Specimen Vault.
# ==========================================
country_event = {
	id = xeno_pic_events.3
	title = xeno_pic_events.3.name
	desc = {
		trigger = { check_variable = { which = xeno_pic3_variant value = 0 } }
		text = xeno_pic_events.3.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic3_variant value = 1 } }
		text = xeno_pic_events.3.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic3_variant value = 0 } }
		picture = GFX_evt_Hive_Female_captured_leader1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic3_variant value = 1 } }
		picture = GFX_evt_Hive_Female_captured_leader2
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic3_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic3_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.3.a
		# Submit to the Breeding Pit — growth bonus
		add_modifier = { modifier = xenomorph_breeding_pit_productivity days = 1800 }
		add_resource = { food = 500 }
	}
	option = {
		name = xeno_pic_events.3.b
		# Assign to Specimen Vault — research bonus
		add_resource = { society_research = 800 engineering_research = 400 }
	}
	option = {
		name = xeno_pic_events.3.c
		# Execute and harvest — unity bonus
		add_resource = { unity = 300 }
	}
}

# ==========================================
# xeno_pic_events.4 — Captured Leader (Female, alt image 2)
# ==========================================
country_event = {
	id = xeno_pic_events.4
	title = xeno_pic_events.4.name
	desc = {
		trigger = { check_variable = { which = xeno_pic4_variant value = 0 } }
		text = xeno_pic_events.4.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic4_variant value = 1 } }
		text = xeno_pic_events.4.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic4_variant value = 0 } }
		picture = GFX_evt_Hive_Female_captured_leader2
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic4_variant value = 1 } }
		picture = GFX_evt_Hive_Female_captured_leader3
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic4_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic4_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.4.a
		add_modifier = { modifier = xenomorph_breeding_pit_productivity days = 1800 }
		add_resource = { food = 500 }
	}
	option = {
		name = xeno_pic_events.4.b
		add_resource = { society_research = 800 engineering_research = 400 }
	}
}

# ==========================================
# xeno_pic_events.5 — Captured Leader (Female, alt image 3)
# ==========================================
country_event = {
	id = xeno_pic_events.5
	title = xeno_pic_events.5.name
	desc = {
		trigger = { check_variable = { which = xeno_pic5_variant value = 0 } }
		text = xeno_pic_events.5.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic5_variant value = 1 } }
		text = xeno_pic_events.5.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic5_variant value = 0 } }
		picture = GFX_evt_Hive_Female_captured_leader3
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic5_variant value = 1 } }
		picture = GFX_evt_Hive_Female_captured_leader1
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic5_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic5_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.5.a
		add_modifier = { modifier = xenomorph_breeding_pit_productivity days = 1800 }
		add_resource = { food = 500 }
	}
	option = {
		name = xeno_pic_events.5.b
		add_resource = { society_research = 800 engineering_research = 400 }
	}
}

# ==========================================
# xeno_pic_events.6 — Captured Pop (Female)
# Shown to the Xenomorph empire when pops are captured.
# ==========================================
country_event = {
	id = xeno_pic_events.6
	title = xeno_pic_events.6.name
	desc = xeno_pic_events.6.desc

	picture = {
		trigger = { always = yes }
		picture = GFX_evt_Hive_Female_captured_pop1
	}

	is_triggered_only = yes

	option = {
		name = xeno_pic_events.6.a
		# Process in Host Processing Bay — growth
		add_resource = { food = 300 }
		add_modifier = { modifier = xenomorph_captured_pop_processing days = 720 }
	}
	option = {
		name = xeno_pic_events.6.b
		# Send to Milk Extraction Station — food income
		add_resource = { food = 600 }
	}
	option = {
		name = xeno_pic_events.6.c
		# Send to Specimen Vault — research
		add_resource = { society_research = 400 }
	}
}

# ==========================================
# xeno_pic_events.7 — Captured Queen (1)
# Shown when the Xenomorph empire captures an enemy leader of high rank.
# ==========================================
country_event = {
	id = xeno_pic_events.7
	title = xeno_pic_events.7.name
	desc = {
		trigger = { check_variable = { which = xeno_pic7_variant value = 0 } }
		text = xeno_pic_events.7.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic7_variant value = 1 } }
		text = xeno_pic_events.7.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic7_variant value = 0 } }
		picture = GFX_evt_Hive_Female_captured_queen1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic7_variant value = 1 } }
		picture = GFX_evt_Hive_Female_captured_queen2
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic7_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic7_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.7.a
		# Integrate into the Hive — major growth and unity
		add_modifier = { modifier = xenomorph_queen_absorbed days = 3600 }
		add_resource = { unity = 500 food = 1000 }
	}
	option = {
		name = xeno_pic_events.7.b
		# Study her — major research bonus
		add_resource = { society_research = 1500 engineering_research = 800 }
	}
}

# ==========================================
# xeno_pic_events.8 — Captured Queen (2)
# ==========================================
country_event = {
	id = xeno_pic_events.8
	title = xeno_pic_events.8.name
	desc = {
		trigger = { check_variable = { which = xeno_pic8_variant value = 0 } }
		text = xeno_pic_events.8.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic8_variant value = 1 } }
		text = xeno_pic_events.8.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic8_variant value = 0 } }
		picture = GFX_evt_Hive_Female_captured_queen2
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic8_variant value = 1 } }
		picture = GFX_evt_Hive_Female_captured_queen3
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic8_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic8_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.8.a
		add_modifier = { modifier = xenomorph_queen_absorbed days = 3600 }
		add_resource = { unity = 500 food = 1000 }
	}
	option = {
		name = xeno_pic_events.8.b
		add_resource = { society_research = 1500 engineering_research = 800 }
	}
}

# ==========================================
# xeno_pic_events.9 — Captured Queen (3)
# ==========================================
country_event = {
	id = xeno_pic_events.9
	title = xeno_pic_events.9.name
	desc = {
		trigger = { check_variable = { which = xeno_pic9_variant value = 0 } }
		text = xeno_pic_events.9.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic9_variant value = 1 } }
		text = xeno_pic_events.9.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic9_variant value = 0 } }
		picture = GFX_evt_Hive_Female_captured_queen3
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic9_variant value = 1 } }
		picture = GFX_evt_Hive_Female_captured_queen1
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic9_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic9_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.9.a
		add_modifier = { modifier = xenomorph_queen_absorbed days = 3600 }
		add_resource = { unity = 500 food = 1000 }
	}
	option = {
		name = xeno_pic_events.9.b
		add_resource = { society_research = 1500 engineering_research = 800 }
	}
}

# ==========================================
# xeno_pic_events.10 — Victory (Female, image 1)
# Shown to the Xenomorph empire after winning a ground battle.
# ==========================================
country_event = {
	id = xeno_pic_events.10
	title = xeno_pic_events.10.name
	desc = {
		trigger = { check_variable = { which = xeno_pic10_variant value = 0 } }
		text = xeno_pic_events.10.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic10_variant value = 1 } }
		text = xeno_pic_events.10.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic10_variant value = 0 } }
		picture = GFX_evt_Hive_Female_Pleasure_1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic10_variant value = 1 } }
		picture = GFX_evt_Hive_Female_Pleasure_2
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic10_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic10_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.10.a
		add_resource = { unity = 200 food = 300 }
	}
}

# ==========================================
# xeno_pic_events.11 — Victory (Female, image 2)
# ==========================================
country_event = {
	id = xeno_pic_events.11
	title = xeno_pic_events.11.name
	desc = {
		trigger = { check_variable = { which = xeno_pic11_variant value = 0 } }
		text = xeno_pic_events.11.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic11_variant value = 1 } }
		text = xeno_pic_events.11.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic11_variant value = 0 } }
		picture = GFX_evt_Hive_Female_Pleasure_2
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic11_variant value = 1 } }
		picture = GFX_evt_Hive_Female_Pleasure_3
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic11_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic11_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.11.a
		add_resource = { unity = 200 food = 300 }
	}
}

# ==========================================
# xeno_pic_events.12 — Victory (Female, image 3)
# ==========================================
country_event = {
	id = xeno_pic_events.12
	title = xeno_pic_events.12.name
	desc = {
		trigger = { check_variable = { which = xeno_pic12_variant value = 0 } }
		text = xeno_pic_events.12.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic12_variant value = 1 } }
		text = xeno_pic_events.12.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic12_variant value = 0 } }
		picture = GFX_evt_Hive_Female_Pleasure_3
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic12_variant value = 1 } }
		picture = GFX_evt_Hive_Female_Pleasure_4
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic12_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic12_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.12.a
		add_resource = { unity = 200 food = 300 }
	}
}

# ==========================================
# xeno_pic_events.13 — Victory (Female, image 4)
# ==========================================
country_event = {
	id = xeno_pic_events.13
	title = xeno_pic_events.13.name
	desc = {
		trigger = { check_variable = { which = xeno_pic13_variant value = 0 } }
		text = xeno_pic_events.13.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic13_variant value = 1 } }
		text = xeno_pic_events.13.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic13_variant value = 0 } }
		picture = GFX_evt_Hive_Female_Pleasure_4
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic13_variant value = 1 } }
		picture = GFX_evt_Hive_Female_Pleasure_1
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic13_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic13_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.13.a
		add_resource = { unity = 200 food = 300 }
	}
}

# ==========================================
# xeno_pic_events.14 — Victory (Female, victory image 1)
# ==========================================
country_event = {
	id = xeno_pic_events.14
	title = xeno_pic_events.14.name
	desc = {
		trigger = { check_variable = { which = xeno_pic14_variant value = 0 } }
		text = xeno_pic_events.14.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic14_variant value = 1 } }
		text = xeno_pic_events.14.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic14_variant value = 0 } }
		picture = GFX_evt_Hive_Female_victory1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic14_variant value = 1 } }
		picture = GFX_evt_Hive_Female_victory_2
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic14_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic14_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.14.a
		add_resource = { unity = 300 food = 500 }
	}
}

# ==========================================
# xeno_pic_events.15 — Victory (Female, victory image 2)
# ==========================================
country_event = {
	id = xeno_pic_events.15
	title = xeno_pic_events.15.name
	desc = {
		trigger = { check_variable = { which = xeno_pic15_variant value = 0 } }
		text = xeno_pic_events.15.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic15_variant value = 1 } }
		text = xeno_pic_events.15.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic15_variant value = 0 } }
		picture = GFX_evt_Hive_Female_victory_2
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic15_variant value = 1 } }
		picture = GFX_evt_Hive_Female_victory1
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic15_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic15_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.15.a
		add_resource = { unity = 300 food = 500 }
	}
}

# ==========================================
# xeno_pic_events.16 — Male Pleasure (image 1)
# ==========================================
country_event = {
	id = xeno_pic_events.16
	title = xeno_pic_events.16.name
	desc = {
		trigger = { check_variable = { which = xeno_pic16_variant value = 0 } }
		text = xeno_pic_events.16.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic16_variant value = 1 } }
		text = xeno_pic_events.16.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic16_variant value = 0 } }
		picture = GFX_evt_Hive_male_Pleasure_1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic16_variant value = 1 } }
		picture = GFX_evt_Hive_male_Pleasure_2
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic16_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic16_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.16.a
		add_resource = { unity = 200 food = 300 }
	}
}

# ==========================================
# xeno_pic_events.17 — Male Pleasure (image 2)
# ==========================================
country_event = {
	id = xeno_pic_events.17
	title = xeno_pic_events.17.name
	desc = {
		trigger = { check_variable = { which = xeno_pic17_variant value = 0 } }
		text = xeno_pic_events.17.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic17_variant value = 1 } }
		text = xeno_pic_events.17.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic17_variant value = 0 } }
		picture = GFX_evt_Hive_male_Pleasure_2
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic17_variant value = 1 } }
		picture = GFX_evt_Hive_male_Pleasure_1
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic17_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic17_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.17.a
		add_resource = { unity = 200 food = 300 }
	}
}

# ==========================================
# xeno_pic_events.18 — Male Victory
# ==========================================
country_event = {
	id = xeno_pic_events.18
	title = xeno_pic_events.18.name
	desc = {
		trigger = { check_variable = { which = xeno_pic18_variant value = 0 } }
		text = xeno_pic_events.18.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic18_variant value = 1 } }
		text = xeno_pic_events.18.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic18_variant value = 0 } }
		picture = GFX_evt_Hive_male_victory1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic18_variant value = 1 } }
		picture = GFX_evt_Hive_Female_victory_2
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic18_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic18_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.18.a
		add_resource = { unity = 300 food = 500 }
	}
}

# ==========================================
# xeno_pic_events.19 — Male Breeding
# ==========================================
country_event = {
	id = xeno_pic_events.19
	title = xeno_pic_events.19.name
	desc = {
		trigger = { check_variable = { which = xeno_pic19_variant value = 0 } }
		text = xeno_pic_events.19.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic19_variant value = 1 } }
		text = xeno_pic_events.19.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic19_variant value = 0 } }
		picture = GFX_evt_hive_male_breeding_3
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic19_variant value = 1 } }
		picture = GFX_evt_Hive_Female_Pleasure_4
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic19_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic19_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.19.a
		add_modifier = { modifier = xenomorph_breeding_pit_productivity days = 1800 }
		add_resource = { food = 400 }
	}
}

# ==========================================
# xeno_pic_events.20 — Tentacle Capture (1)
# Shown when a Xenomorph espionage operation captures pops.
# ==========================================
country_event = {
	id = xeno_pic_events.20
	title = xeno_pic_events.20.name
	desc = {
		trigger = { check_variable = { which = xeno_pic20_variant value = 0 } }
		text = xeno_pic_events.20.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic20_variant value = 1 } }
		text = xeno_pic_events.20.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic20_variant value = 0 } }
		picture = GFX_evt_Hive_female_tentacle_capture1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic20_variant value = 1 } }
		picture = GFX_evt_Hive_female_tentacle_capture2
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic20_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic20_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.20.a
		add_resource = { food = 400 unity = 100 }
	}
}

# ==========================================
# xeno_pic_events.21 — Tentacle Capture (2)
# ==========================================
country_event = {
	id = xeno_pic_events.21
	title = xeno_pic_events.21.name
	desc = {
		trigger = { check_variable = { which = xeno_pic21_variant value = 0 } }
		text = xeno_pic_events.21.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic21_variant value = 1 } }
		text = xeno_pic_events.21.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic21_variant value = 0 } }
		picture = GFX_evt_Hive_female_tentacle_capture2
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic21_variant value = 1 } }
		picture = GFX_evt_Hive_female_tentacle_capture3
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic21_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic21_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.21.a
		add_resource = { food = 400 unity = 100 }
	}
}

# ==========================================
# xeno_pic_events.22 — Tentacle Capture (3)
# ==========================================
country_event = {
	id = xeno_pic_events.22
	title = xeno_pic_events.22.name
	desc = {
		trigger = { check_variable = { which = xeno_pic22_variant value = 0 } }
		text = xeno_pic_events.22.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic22_variant value = 1 } }
		text = xeno_pic_events.22.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic22_variant value = 0 } }
		picture = GFX_evt_Hive_female_tentacle_capture3
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic22_variant value = 1 } }
		picture = GFX_evt_Hive_female_tentacle_capture1
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic22_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic22_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.22.a
		add_resource = { food = 400 unity = 100 }
	}
}

# ==========================================
# xeno_pic_events.23 — Swarm Hold Established
# Shown when a Xenomorph branch office is established on a foreign world.
# ==========================================
country_event = {
	id = xeno_pic_events.23
	title = xeno_pic_events.23.name
	desc = {
		trigger = { check_variable = { which = xeno_pic23_variant value = 0 } }
		text = xeno_pic_events.23.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic23_variant value = 1 } }
		text = xeno_pic_events.23.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic23_variant value = 0 } }
		picture = GFX_evt_Hive_Female_Swarm_Hold_established
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic23_variant value = 1 } }
		picture = GFX_evt_Hive_Female_victory1
	}

	is_triggered_only = yes

	trigger = {
		any_owned_species = { has_trait = trait_xenomorph }
	}

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic23_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic23_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.23.a
		add_resource = { unity = 200 influence = 50 }
	}
}

# ==========================================
# xeno_pic_events.24 — Wild Xenomorph Hunters
# Shown when feral xenomorphs are encountered on a planet.
# ==========================================
planet_event = {
	id = xeno_pic_events.24
	title = xeno_pic_events.24.name
	desc = {
		trigger = { check_variable = { which = xeno_pic24_variant value = 0 } }
		text = xeno_pic_events.24.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic24_variant value = 1 } }
		text = xeno_pic_events.24.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic24_variant value = 0 } }
		picture = GFX_evt_Hive_wild_xenomorph_hunters
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic24_variant value = 1 } }
		picture = GFX_evt_Hive_Female_Swarm_Hold_established
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic24_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic24_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.24.a
		# Attempt to pacify — chance of success
		random_list = {
			50 = {
				remove_deposit = d_feral_xenomorphs
				add_deposit = d_pacified_xenomorphs
			}
			50 = {
				add_modifier = { modifier = xenomorph_post_battle_shock days = 180 }
			}
		}
	}
	option = {
		name = xeno_pic_events.24.b
		# Exterminate — removes deposit, small mineral gain
		remove_deposit = d_feral_xenomorphs
		add_deposit = d_xenomorph_remains
	}
	option = {
		name = xeno_pic_events.24.c
		# Leave them — no action
	}
}

# ==========================================
# xeno_pic_events.25 — Post-Conquest Planet Event
# Fires when the Xenomorph empire takes a planet.
# Describes the fate of the surviving population.
# ==========================================
planet_event = {
	id = xeno_pic_events.25
	title = xeno_pic_events.25.name
	desc = {
		trigger = { check_variable = { which = xeno_pic25_variant value = 0 } }
		text = xeno_pic_events.25.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic25_variant value = 1 } }
		text = xeno_pic_events.25.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic25_variant value = 0 } }
		picture = GFX_evt_Hive_Female_battle_lost2
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic25_variant value = 1 } }
		picture = GFX_evt_Hive_Female_victory1
	}

	is_triggered_only = yes

	trigger = {
		owner = { any_owned_species = { has_trait = trait_xenomorph } }
		any_owned_pop_group = { is_xenomorph = no }
	}

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic25_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic25_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.25.a
		# Process survivors — growth bonus
		add_modifier = { modifier = xenomorph_captured_pop_processing days = 1080 }
		add_resource = { food = 800 }
	}
	option = {
		name = xeno_pic_events.25.b
		# Condition survivors — stability bonus
		add_modifier = { modifier = xenomorph_pheromone_compliance days = 1800 }
		planet_stability = { add = 10 }
	}
	option = {
		name = xeno_pic_events.25.c
		# Preserve for study — research bonus
		add_resource = { society_research = 600 engineering_research = 300 }
	}
}

# ==========================================
# xeno_pic_events.26 — Raid Operation Success
# Fires when the Xenomorph espionage raid succeeds.
# ==========================================
country_event = {
	id = xeno_pic_events.26
	title = xeno_pic_events.26.name
	desc = {
		trigger = { check_variable = { which = xeno_pic26_variant value = 0 } }
		text = xeno_pic_events.26.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic26_variant value = 1 } }
		text = xeno_pic_events.26.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic26_variant value = 0 } }
		picture = GFX_evt_Hive_female_tentacle_capture1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic26_variant value = 1 } }
		picture = GFX_evt_Hive_female_tentacle_capture2
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic26_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic26_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.26.a
		# Pops delivered to the Breeding Pit
		add_modifier = { modifier = xenomorph_breeding_pit_productivity days = 1080 }
		add_resource = { food = 600 unity = 150 }
	}
	option = {
		name = xeno_pic_events.26.b
		# Pops delivered to the Specimen Vault
		add_resource = { society_research = 500 engineering_research = 250 }
	}
}

# ==========================================
# xeno_pic_events.27 — Ground Battle Won (Xenomorph attacker)
# Fires when the Xenomorph empire wins a ground battle.
# Random chance to capture pops or a leader.
# ==========================================
country_event = {
	id = xeno_pic_events.27
	title = xeno_pic_events.27.name
	desc = {
		trigger = { check_variable = { which = xeno_pic27_variant value = 0 } }
		text = xeno_pic_events.27.desc
	}
	desc = {
		trigger = { check_variable = { which = xeno_pic27_variant value = 1 } }
		text = xeno_pic_events.27.desc_v2
	}

	picture = {
		trigger = { check_variable = { which = xeno_pic27_variant value = 0 } }
		picture = GFX_evt_Hive_Female_victory1
	}
	picture = {
		trigger = { check_variable = { which = xeno_pic27_variant value = 1 } }
		picture = GFX_evt_Hive_male_victory1
	}

	is_triggered_only = yes

	immediate = {
		random_list = {
			50 = { set_variable = { which = xeno_pic27_variant value = 0 } }
			50 = { set_variable = { which = xeno_pic27_variant value = 1 } }
		}
	}

	option = {
		name = xeno_pic_events.27.a
		# Harvest the fallen — food and growth
		add_resource = { food = 500 }
		add_modifier = { modifier = xenomorph_post_victory_surge days = 720 }
	}
	option = {
		name = xeno_pic_events.27.b
		# Capture and process survivors — move pop groups from the saved battle planet.
		hidden_effect = { xeno_kidnap_saved_planet_pops = yes }
		add_modifier = { modifier = xenomorph_breeding_pit_productivity days = 1080 }
		add_resource = { food = 300 unity = 200 }
	}
	option = {
		name = xeno_pic_events.27.c
		# Drag an eligible leader into the Hive's custody.
		hidden_effect = { xeno_kidnap_saved_country_leader = yes }
		add_resource = { society_research = 300 unity = 150 }
	}
}


# ==========================================
# xeno_pic_events.28 — Hidden Ground Battle Raid Gate
# Scope follows base-game on_planet_attackers_win:
# THIS = country, lead attacker; FROM = planet owner; FROMFROM = planet.
# Saves attacker, defender, and planet targets before firing the visible capture event.
# ==========================================
country_event = {
	id = xeno_pic_events.28
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_owned_species = { has_trait = trait_xenomorph }
		from = { NOT = { any_owned_species = { has_trait = trait_xenomorph } } }
		fromfrom = { any_owned_pop_group = { is_xenomorph = no } }
	}

	immediate = {
		save_event_target_as = xeno_raid_attacker
		from = { save_event_target_as = xeno_raid_defender }
		fromfrom = { save_event_target_as = xeno_raid_planet }

		# Main victory event always fires
		country_event = { id = xeno_pic_events.27 }

		# Notify the defeated attacker side (if non-Xeno) with a battle-lost popup.
		# 50% chance to show captured-leader popup if there's an eligible leader.
		from = {
			if = {
				limit = {
					NOT = { any_owned_species = { has_trait = trait_xenomorph } }
				}
				random_list = {
					50 = { country_event = { id = xeno_pic_events.1 } }
					50 = { country_event = { id = xeno_pic_events.2 } }
				}
			}
		}
	}
}

# ==========================================
# xeno_pic_events.29 — Hidden Defender Victory Gate
# Scope follows base-game on_planet_defenders_win:
# THIS = country, planet owner; FROM = country, attack leader; FROMFROM = planet.
# Keeps the defender-victory picture event from firing for unrelated battles.
# ==========================================
country_event = {
	id = xeno_pic_events.29
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_owned_species = { has_trait = trait_xenomorph }
	}

	immediate = {
		save_event_target_as = xeno_raid_defender
		from = { save_event_target_as = xeno_raid_attacker }
		fromfrom = { save_event_target_as = xeno_raid_planet }

		# Patriarchs civic -> male pleasure/victory variants.
		# Matriarchs civic -> female pleasure/victory variants.
		# Otherwise random from all variants.
		if = {
			limit = { has_civic = civic_xenomorph_patriarchs_dominion }
			random_list = {
				30 = { country_event = { id = xeno_pic_events.16 } }
				30 = { country_event = { id = xeno_pic_events.17 } }
				40 = { country_event = { id = xeno_pic_events.18 } }
			}
		}
		else_if = {
			limit = { has_civic = civic_xenomorph_matriarchs_hunger }
			random_list = {
				20 = { country_event = { id = xeno_pic_events.10 } }
				20 = { country_event = { id = xeno_pic_events.11 } }
				20 = { country_event = { id = xeno_pic_events.12 } }
				10 = { country_event = { id = xeno_pic_events.13 } }
				15 = { country_event = { id = xeno_pic_events.14 } }
				15 = { country_event = { id = xeno_pic_events.15 } }
			}
		}
		else = {
			random_list = {
				15 = { country_event = { id = xeno_pic_events.10 } }
				15 = { country_event = { id = xeno_pic_events.11 } }
				10 = { country_event = { id = xeno_pic_events.12 } }
				10 = { country_event = { id = xeno_pic_events.13 } }
				10 = { country_event = { id = xeno_pic_events.14 } }
				10 = { country_event = { id = xeno_pic_events.15 } }
				10 = { country_event = { id = xeno_pic_events.16 } }
				10 = { country_event = { id = xeno_pic_events.17 } }
				10 = { country_event = { id = xeno_pic_events.18 } }
			}
		}
	}
}


# ==========================================
# xeno_pic_events.30 — Tentacle Capture Dispatcher (hidden)
# Hidden dispatcher for espionage/raid events that want to show a tentacle-capture
# popup. Picks one of .20-.22 at random. Use from external events as:
#   country_event = { id = xeno_pic_events.30 }
# ==========================================
country_event = {
	id = xeno_pic_events.30
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_owned_species = { has_trait = trait_xenomorph }
	}

	immediate = {
		random_list = {
			34 = { country_event = { id = xeno_pic_events.20 } }
			33 = { country_event = { id = xeno_pic_events.21 } }
			33 = { country_event = { id = xeno_pic_events.22 } }
		}
	}
}

# ==========================================
# xeno_pic_events.31 — Captured-Leader Dispatcher (hidden)
# Hidden dispatcher for the leader-capture variants .3/.4/.5.
# Use from external events when a high-rank leader is captured:
#   country_event = { id = xeno_pic_events.31 }
# ==========================================
country_event = {
	id = xeno_pic_events.31
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_owned_species = { has_trait = trait_xenomorph }
	}

	immediate = {
		random_list = {
			40 = { country_event = { id = xeno_pic_events.3 } }
			30 = { country_event = { id = xeno_pic_events.4 } }
			30 = { country_event = { id = xeno_pic_events.5 } }
		}
	}
}

# ==========================================
# xeno_pic_events.32 — Captured-Queen Dispatcher (hidden)
# Hidden dispatcher for queen-capture variants .7/.8/.9.
# Fire from external events when an enemy queen-tier leader is captured.
# ==========================================
country_event = {
	id = xeno_pic_events.32
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_owned_species = { has_trait = trait_xenomorph }
	}

	immediate = {
		random_list = {
			34 = { country_event = { id = xeno_pic_events.7 } }
			33 = { country_event = { id = xeno_pic_events.8 } }
			33 = { country_event = { id = xeno_pic_events.9 } }
		}
	}
}

###############################################
# === xenomorph_provoke_events.txt ===
###############################################
###############################################
# XENOMORPH PROVOCATION EVENTS (Q2)
#
# Fired ON the target empire when a Xenomorph hive parades a captured leader
# taken from them. ROOT = the target (recipient). FROM = the Xenomorph hive
# (set via scopes = { from = root } in the diplomatic action's on_accept).
###############################################

namespace = xeno_provoke

# ---- .1 The Hive parades your captured leader --------------------------------
country_event = {
	id = xeno_provoke.1
	title = "xeno_provoke.1.title"
	desc = "xeno_provoke.1.desc"
	picture = GFX_evt_alien_planet
	is_triggered_only = yes

	immediate = {
		# The humiliation costs the target a brief stability shock.
		capital_scope = {
			add_modifier = {
				modifier = xeno_paraded_humiliation
				days = 1800
			}
		}
	}

	option = {
		name = "xeno_provoke.1.swallow"
		# They endure the insult.
	}
}
